package mop.controller;

import java.beans.PropertyChangeEvent;
import mop.exception.IllegalDescriptionException;
import mop.exception.IllegalDuplicationException;
import mop.model.World;
import mop.model.project.Project;
import mop.model.project.ProjectInterface;

/**
 * CreateProjectController
 * 
 * Use case controller for the creation of a new project. 
 * (use case 5)
 * 
 * @author	MOP Team 7
 */
public class CreateProjectController extends UseCaseController
{

	/**
	 * @see UseCaseController#UseCaseController(World)
	 */
	public CreateProjectController(World world)
	{
		super(world);
	}
	
	/**
	 * Use case : Create a project
	 * 
	 * @param	description
	 * 			The description of the new Project.
	 * @post	The Project is added to the Project database.
	 * 			| projectDatabase.contains(this)
	 * @throws  IllegalDescriptionException
	 * 			Thrown when the Project description is invalid.
	 * @throws 	IllegalDuplicationException 
	 * 			Thrown when a Project with the same description already exists in the database.
	 */
	public ProjectInterface createProject(String description) 
		throws IllegalDescriptionException, IllegalDuplicationException
	{
		return new Project(getWorld().getProjectDataBase(), description);
	}
	
	/***************************************************************************
	 * 								Visit
	 ***************************************************************************/
	
	/**
	 * Make a CallBack to the visitor
	 * @param v the visitor
	 */
	public void visit(ControllerVisitor v)
	{
		v.action(this);
	}
}